package com.tuozixuan.javafx.control;


import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.scene.web.HTMLEditor;
import javafx.stage.Stage;

public class HtmlEditorDemo extends Application {
	
    public static void main(String[] args) {
        launch(args);
    }

	@Override
	public void start(Stage primaryStage) throws Exception {
		
		HTMLEditor htmlEditor = new HTMLEditor();
        htmlEditor.setPrefHeight(245);
        String INITIAL_TEXT = "Lorem ipsum dolor sit "
            + "amet, consectetur adipiscing elit. Nam tortor felis, pulvinar "
            + "aliquam sagittis gravida eu dolor. Etiam sit amet ipsum "
            + "sem.";
        htmlEditor.setHtmlText(INITIAL_TEXT);
        
        
        Button showHTMLButton = new Button("Produce HTML Code");
        
        VBox vbox = new VBox();
        vbox.getChildren().addAll(htmlEditor,showHTMLButton);
        showHTMLButton.setOnAction((ActionEvent arg0) -> {
          System.out.println(htmlEditor.getHtmlText());
        });
		
        Scene scene = new Scene(vbox, 300, 300);

        primaryStage.setScene(scene);
        primaryStage.sizeToScene();
        primaryStage.show();
	}

}
